package com.changgou.business.service.impl;

import com.changgou.business.dao.TimeMapper;
import com.changgou.business.pojo.Time;
import com.changgou.business.service.TimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TimeServiceImpl implements TimeService {

    @Autowired
    private TimeMapper timeMapper;
    /**
     * 查询时间段
     * @return
     */
    @Override
    public List<Time> findAll() {
        List<Time> times = timeMapper.selectAll();
        return times;
    }

    @Override
    public void deleteById(Integer id) {
        timeMapper.deleteByPrimaryKey(id);
    }

    /**
     * 添加秒杀时间段
     * @param time
     */
    public void add(Time time) {
        timeMapper.insert(time);
    }

    /**
     * 时间段的启用、关闭
     * @param time
     */
    public void updateStatus(Time time) {
        timeMapper.updateByPrimaryKey(time);
    }
}
